<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>选择场馆</title>
    <script src="js/flexible.js"></script>
    <link rel="stylesheet" href="css/flexible.css">
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/homePage.css">
    <link rel="stylesheet" href="css/vant.css">
    <script src="js/vue.js"></script>
    <script src="js/axios.js"></script>
    <script src="js/qs.js"></script>
    <script src="js/MD5.js"></script>
    <script src="js/vant.js"></script>
</head>
<body>
    <div class="xzmd_main" id="app">
        <div class="md_list" v-for="item in list" @click="select(item.id,item.Bid,item.Openid)">
            <img :src="item.Logo" onerror="this.src='images/shopMoren.jpg'">
            <br>
            <span>{{item.Vname}}</span>
        </div>
    </div>
</body>
<script>
var app = new Vue({
    el: '#app',
    data: {
       list:[],
       from:{
            Bid:'',
            Vid:'',
            Phone:'',
            Openid:''
       }
    },
    created(){
        this.setCanS()
    },
    methods: {
        //设置参数
        setCanS(){
            let lists=JSON.parse(sessionStorage.getItem("venueset_list"))
            for(let i in lists){
                this.list.push(lists[i])
            }
            console.log(this.list)
        },
        select(Vid,Bid,Openid){
            //跳转到首页
            let type="logo"
            this.from.Bid=Bid
            this.from.Vid=Vid
            this.from.Openid=Openid
            this.from.Phone=sessionStorage.getItem('vxPhone')
            sessionStorage.setItem('type',type)
            let from =JSON.stringify(this.from)
            let sign=md5(from)
            let params={
                from:from,
                sign:sign
            }
            axios.post('/mobileapi/login_staff.php?act=login_ven',
            Qs.stringify(params)).then(data => {
                let { msg, code} = data.data
                    if (code !== 200) {
                        window.vant.Toast.fail(msg)
                    } else {
                        data = data.data
                        sessionStorage.setItem('logo','0')
                        sessionStorage.setItem('token',data.data.Gtoken)
                        this.vid=data.data.Vid
                        sessionStorage.setItem('vid',this.vid)
                        let type="logo"
                        localStorage.setItem('adviser','1')
                        localStorage.setItem('adviservid',data.data.Vid)
                        localStorage.setItem('adviserGtoken',data.data.Gtoken)
                        let timeLoc=new Date()
                        localStorage.setItem('adviserTime',new Date(timeLoc.getTime() + 365*24*60*60*1000))
                        sessionStorage.setItem('type',type)
                        window.location.href='index.html?vid='+this.vid+'&type='+type+''
                    }
                }).catch(function (error) { 
                    console.log(error); 
            });
        }
    }  
})    
</script>
</html>
